<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    


    <script>
        let nums = [];//声明一个空数组,使用字面量方式声明
        let numbers = [12,43,65,78, 98,67];
        numbers[6]=100;
        numbers[numbers.length] = 200;
        numbers.push(300);
        numbers.push(400);
        for (let num of numbers) {            
            document.write(num+"<br/>");
        }

        document.write("<hr/>");
        //创建数组对象
        let arr = new Array(2);
        document.write("数组的长度为:"+arr.length+"<br/>");
        arr[0] = 12;
        arr[1] = 21;
        arr[2] = 33;
        arr.push(44);
        arr.push(45);
        arr.push(100,200,300,400);
        document.write("数组的长度为:"+arr.length+"<br/>");
        for (const num of arr) {
            document.write(num+"<br/>");
        }
    </script>
</body>
</html>